import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      meta: { title: '首页' } ,
      component: () => import('@/views/Home.vue')
    },
    {
      path: '/login',
      meta: { title: '登录' },
      component: () => import('@/views/Login.vue')
    },
    {
      path: '/home',
      meta: { title: '首页' },
      component: () => import('@/views/Home.vue')
    },
    {
      path: '/practice/list/:id',
      meta: { title: '练习' } ,
      component: () => import('@/views/practice/List.vue')
    },
    {
      path: '/exam/list/:id',
      meta: { title: '考试' },
      component: () => import('@/views/exam/List.vue')
    }
    ,
    {
      path: '/exam/result/:id',
      meta: { title: '考试结果' } ,
      component: () => import('@/views/exam/Result.vue')
    }
  ]
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '保险考典';
  next()
})

export default router
